<div id="mainContent">

<script type="text/javascript">
function changeVisibility(id) {
  if (document.getElementById(id).style.visibility == "collapse")
    document.getElementById(id).style.visibility = "visible";
  else
    document.getElementById(id).style.visibility = "collapse";
}
</script>
<script type="text/javascript">
function addTag(tag) {
    old_value = document.getElementById("tag_list_field").value
    if (old_value == null || old_value.length ==0) {
        document.getElementById("tag_list_field").value=tag;
    } else {
        old_value_arr = old_value.split(", ")
        index = old_value_arr.indexOf(tag);
        if (index != -1) {
            old_value_arr.splice(index, 1);
        } else {
            old_value_arr.push(tag);
        }
        document.getElementById("tag_list_field").value=old_value_arr.join(", ");
    }
}
</script>
</head>
<% form_for(:stat, :url => stats_path) do |f| %>
        <%= f.hidden_field :project_hash %>
        <%= f.hidden_field :project_url %>
        <%= f.hidden_field :created_at %>
        <%= f.hidden_field :crap %>
        <%= f.hidden_field :crap_load %>
        <%= f.hidden_field :crap_methods %>
        <%= f.hidden_field :total_methods %>
        <%= f.hidden_field :ones %>
        <%= f.hidden_field :twos %>
        <%= f.hidden_field :fours %>
        <%= f.hidden_field :eights %>
        <%= f.hidden_field :sixteens %>
        <%= f.hidden_field :thirtytwos %>
        <%= f.hidden_field :sixtyfours%>
        <%= f.hidden_field :one28s %>
        <%= f.hidden_field :two56s %>

        

<div style="text-align:center">
<span style="font-size:22px;font-weight:bold">CRAP Summary Sharing</span><br/>
for<br/>
 <%=h @stat.project_url(true) %><br/>
 <div style="font-size: 8px">(<%= @stat.created_at.strftime('%m/%d/%y at %H:%M') %>)</div>
</div>

<%= error_messages_for :stat %>
  <div id="sharing;text-align:center;padding-left:5em;width:25em">
    <table>
      <tr>
        <td style="text-align:left;vertical-align:top"><%= f.radio_button :shared, false, {:checked => true, :onclick => "changeVisibility('shared_info')"} %></td>
      <td style="text-align:left"><b>Share results anonymously</b><br/>
          Project summary numbers will be shared without any identifying information.
          </td></tr>
      <tr><td style="text-align:left;vertical-align:top"><%= f.radio_button :shared, true, {:onclick => "changeVisibility('shared_info')"} %></td>
      <td style="text-align:left"   ><b>Share results publicly</b><br/>
          Project summary numbers will be shared, along with the 'Project Name' and 'Project Homepage' you provide.<br/>
          This is ideal for any projects that want to show how clean their code is.
          </td></tr>
    </table>      
  </div>

  <div id="shared_info" style="visibility: <%= if @stat.shared? then 'visible' else 'collapse' end %>">
    <table>
      <tr><th>Project Name: </th><td>
      <%=f.text_field :project_name  %></td></tr>
      <tr><th>Project Homepage:</th><td>
      <%=f.text_field :project_homepage %></td></tr>
    </table>
  </div>
  <div id="tag_list">
    <table>
      <tr>
        <th>Project Tags: </th>
        <td><%= f.text_field :tag_list, {:size=>100, :id => 'tag_list_field'} %></td>
      </tr>
      <tr><td colspan="2"><span style="font-size: 10px">(Click a tag (below) to add it to the project, or create your own tags, <b>separated by commas.</b>)</span></td></tr>
    </table>
  </div>
   <p style="text-align:left">
    <%= submit_tag "Share and Compare" %>
  </p>
  <div id="tag_cloud" >
<h2 style="width:100%">Available Tags</h2>
<style>
 .css1 { font-size: 10px; }
  .css2 { font-size: 12px; }
  .css3 { font-size: 14px; }
  .css4 { font-size: 16px; }
</style>
<div id="tag_cloud_tags" style="background-color: #fff">
    <% @controller.tag_cloud @tags, %w(css1 css2 css3 css4) do |tag, css_class| %>
    <a href="javascript:addTag('<%=tag.name%>')" id = "<%=css_class%>"><%=tag.name%></a>
  <% end %>
</div>
</div>
    
 

  <% end %>
</div>
